package com.foreknow.demo16;

/**
 * 1.方法的参数可以是父类型(抽象类)
 */
public class TestMethod {
    public void methodA(D d) {
      d.fly();
    }

    public D methodB() {
      D d = new SubD();
      return d;
    }

    public void methodC(B b) {
      b.walk();
    }

    public B methodD() {
      B b = new BImpl();
      return b;
    }

  public static void main(String[] args) {
    TestMethod testMethod = new TestMethod();

    //    D d = new SubD();
    //    testMethod.methodA(d);
    //    D d = testMethod.methodB();
    //    d.fly();
    //    B b = new BImpl();
    //    testMethod.methodC(b);
    B b = testMethod.methodD();
    b.walk();
  }
}
